import java.util.List;

public class FindViewUtils {
	public static String findView(String fileName) {
		List<WidgetIdMapping> mappings = XMLDecoder.getMappingFromFile(fileName);
		StringBuilder sb = new StringBuilder();
		sb.append("private void initView() {\n");
		for(WidgetIdMapping mapping : mappings) {
			sb.append("\t" + mapping.getParam() + 
					" = " + "(" + mapping.getType() + ")" + " v.findViewById(" 
					+ mapping.getId() + ");\n");
		}
		sb.append("}");
		System.out.println(sb.toString());
		return sb.toString();
	}
	
	public static String getViewAnnotion(String fileName) {
		List<WidgetIdMapping> mappings = XMLDecoder.getMappingFromFile(fileName);
		StringBuilder sb = new StringBuilder();
		for(WidgetIdMapping mapping : mappings) {
			sb.append("private " + mapping.getType() + " " + mapping.getParam() + ";\n");
		}
		System.out.println(sb.toString());
		return sb.toString();
	}
}
